import requests

from api import Authorization, HALO_BASE_URL


class CreateArticleTypesApi:

    def __init__(self):
        self.url = HALO_BASE_URL + "/apis/content.halo.run/v1alpha1/categories"
        self.headers = {
            "Authorization": Authorization
        }

    def create_article_type(self):
        payload = {
            "spec": {
                "displayName": "zcl",
                "slug": "zcl",
                "description": "",
                "cover": "",
                "template": "",
                "postTemplate": "",
                "priority": 0,
                "children": [],
                "preventParentPostCascadeQuery": False
            },
            "status": {},
            "apiVersion": "content.halo.run/v1alpha1",
            "kind": "Category",
            "metadata": {
                "name": "",
                "generateName": "category-",
                "annotations": {}
            }
        }

        response = requests.post(url=self.url, json=payload, headers=self.headers)

        return response


